package com.ly.tools;

import com.ly.mapper.SelectionsMapper;
import com.ly.mapper.StudentsMapper;
import com.ly.pojo.Courses;
import com.ly.pojo.Students;
import com.ly.pojo.TStudentClass;
import com.ly.service.CourseService;
import com.ly.service.SelectionService;
import com.ly.service.StudentService;
import com.ly.service.TStudentClassService;
import org.springframework.ai.tool.annotation.Tool;
import org.springframework.ai.tool.annotation.ToolParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CourseRecommendationTools {

    @Autowired
    private SelectionService selectionService;

    @Autowired
    private CourseService courseService;

    @Autowired
    private StudentService studentService;

    @Autowired
    private TStudentClassService tStudentClassService;

    @Tool(description = "基于用户进行课程推荐，类似选择了《数据结构》的同学大都会选择《面向对象》《操作系统》等课程")
    public String answerCourseRelatedQuestion(
            @ToolParam(description = "用户提问中提到的课程名") String targetCourse
    ) {

        // 2. 查询数据库获取真实数据
        String realData = selectionService.getRelatedCoursesStats(targetCourse);

        return realData;
    }

    @Tool(description = "查询全部课程数据")
    public List<Courses> selectAllCourse() {
        List<Courses> allCourseList = courseService.getAllCourseList();
        return allCourseList;
    }

    @Tool(description = "根据用户账号account查询用户信息")
    public String selectUserInfoByAccount(
            @ToolParam(description = "必须使用前端的sessionStorage.getItem('account')获取到当前用户的账号") Long account
    ){
        Students student = studentService.selectBySno(account);
        TStudentClass tStudentClass = tStudentClassService.selectBySno(account);
        return student.toString() + tStudentClass.toString();
    }

}
